home *** CD-ROM | disk | FTP | other *** search
- /*
- Process-Dir.rexx
-
- Example script that applies a plugin-effect to all files of a
- directory
-
- Refer to ArtEffect:Rexx/Rexx.doc for a complete command
- description
-
- Attention: filenames must not include any blank spaces!
- */
-
- OPTIONS RESULTS
- OPTIONS FAILAT 21
- SIGNAL ON ERROR
-
- /* Check for ArtEffect ARexx port */
- IF ~SHOW(P,"ArtEffect") THEN DO
- SAY D2C(7)
- SAY "ATTENTION:"
- SAY "Could not find ArtEffect ARexx port."
- SAY "Please make sure that ArtEffect is running."
- SAY
- EXIT
- END
-
- ADDRESS "ArtEffect"
-
- /* check for rexxsupport.library (necessary for ShowDir) */
- IF ~SHOW('L', "rexxsupport.library") THEN
- IF ~ADDLIB('rexxsupport.library', 0, -30) THEN DO
- REQUESTNOTIFY TITLE '"System error"' PROMPT '"rexxsupport.library
- could not be opened"'
- EXIT 10
- END
-
- /* Filerequester - get a list of all files to be processed */
- REQUESTFILE VAR filterdir PATH "ArtEffect:" TITLE '"Choose directory"' DIR
- IF ~RC = 0 THEN REQUESTNOTIFY TITLE '"An error has occured"' PROMPT '"You cancelled the requester"'
-
- filelist = ShowDir(filterdir, FILE,)
-
- REQUESTRESPONSE VAR inplace TITLE '"Please select..."' PROMPT '"Do you want to save the modified pictures|over the original ones?"' OPTIONS "Yes|No"
-
- IF inplace = 1 THEN REQUESTFILE VAR savepath TITLE '"Choose directory"' DIR
-
- /* keep user from interfering */
- LOCKGUI
-
- /* repeat loop until all files have been processed */
- DO WHILE ~(Compress(filelist) = "")
-
- /* get name of file to be processed */
- currfile = SubWord(filelist, 1, 1)
-
- /* attach full path to filename */
- picpath = filterdir || currfile
-
- /* load the picture */
- LOADPIC picpath
-
- /* change this to the desired plugin */
- DOMETHOD QUIT 'POINTISE'
-
- IF inplace = 0 THEN SAVEPIC NAME picpath PLUGIN 'JFIF-JPEG' /* insert
- desired save format here */
- ELSE DO
- picpath = savepath || currfile
- SAVEPIC NAME picpath PLUGIN 'JFIF-JPEG' /* insert desired save format here */
- END
-
- /* close the picture */
- CLOSEPIC FORCE
-
- /* remove the file that was just processed from the list of files
- still to be processed */
- filelist = SubStr(filelist, Length(currfile)+2)
- END
-
- /* Tell the user everything went fine */
- REQUESTNOTIFY TITLE '"User information"' PROMPT "All pictures were
- processed successfully."
-
- /* return control to user - NEVER forget this! */
- UNLOCKGUI
-
- EXIT
-
- /* this function is executed when an error occurs in the script */
- ERROR:
- /* tell the user in which line of this script to look for the error */
- REQUESTNOTIFY TITLE '"ARexx-Error"' PROMPT "ARexx-error no." RC " has occured in line" SIGL "."
-
- /* do not forget to unlock the GUI */
- UNLOCKGUI
-
- EXIT
-
-